<template>
  <transition name="fadeIn">
    <div v-show="visible" class="tip">
        <div class="title">提示</div>
        <div style="text-align: left">
          <p>{{ props.text }}</p>
        </div>
        <div class="footer">
          <button
            class="config"
            @click="YES"
            @mouseenter="cantForChange"
            @mouseleave="rePlay"
          >
            <span>确认</span>
          </button>
          <button class="cancel" @click="NO">取消</button>
        </div>
    </div>
  </transition>
  <transition name="fadeIn">
    <div class="black" v-show="visible"></div>
  </transition>
</template>

<script setup lang="ts">
import { ref, defineProps, defineEmits, onMounted } from "vue";
const props = defineProps(["text", "onClose", "confirm", "id", "visible"]);
const cantChange = ref<boolean>(true);
const visible = ref<boolean>(false);
onMounted(() => {
  visible.value = true;
});
const cantForChange = () => {
  cantChange.value = false;
};
const rePlay = () => {
  cantChange.value = true;
};
const YES = () => {
  props.confirm();
  visible.value = false;
};
const NO = () => {
  props.onClose();
  visible.value = false;
};
</script>

<style lang="scss" scoped>
@import "../../css/comment/animate.css";
.black {
  width: 100vw;
  height: 100vh;
  background-color: rgba($color: #000000, $alpha: 0.4);
  position: absolute;
  left: 0;
  top: 0;
  z-index: 9999;
}
.tip {
  position: absolute;
  left: 0;
  top: -230px;
  bottom: 0;
  right: 0;
  margin: auto;
  width: 350px;
  height: 150px;
  background-color: rgba(255, 255, 255);
  border-radius: 10px;
  z-index: 99999;
  padding: 0 20px;
  box-sizing: border-box;
  box-shadow: 0 0 8px 0px #555;
  .title{
      margin-top: 16px;
      font-size: 18px;
      color: #333;
      font-weight: 400;

  }
  .footer{
      position: absolute;
      bottom: 10px;
      right: 16px;
      text-align: right;
  }
  p {
    margin-top: 16px;
    margin-left: 24px;
    font-size: 14px;
    color: #606266;
    font-weight: 400;
  }
  .config {
    background-color: #78aff9;
    color: #ffffff;
    font-weight: 400;
    transition: all 0.15s;
    width: 70px;
    &:hover {
      background-color:lighten(#78aff9,5%);
    }
  }
  .cancel {
    background-color: #f4f4f4f5;
    font-weight: 400;
    transition: all 0.15s;
    border: 1px solid #ddd;
    width: 70px;
    &:hover {
      // background-color:lighten(springgreen,20%);
      background-color: #ddd;
    }
  }
  button {
    outline: none;
    height: 30px;
    border: none;
    border-radius: 5px;
    margin: 15px 8px;
  }
}
</style>
